Skip to content

Conversation

@Urgau
Copy link
Member

@Urgau Urgau commented Dec 17, 2025

This is done to avoid leaking the relative paths to the standard library after the overall of filenames in #149709.

Noted that the paths were already leaking before, but to a lesser extent since most (but not all) the paths embedded in the distributed rlib were absolute.

In general Cargo compiles workspace members with relative paths, so it's better anyway to remap the relative path.

In addition to our tests I have manually confirmed that it also works as expected for the printed diagnostics paths.

cf. https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/remapping.20of.20the.20standard.20library/near/564093571

r? @jieyouxu

This is done to avoid leaking the relative paths to the standard
library after the overall of filenames.

Noted that the paths were already leaking before, but to a lesser extent
since the paths embedded in the distributed `rlib` were absolute.

In general Cargo compiles workspace members with relative paths, so it's
better anyway to remap the relative path.

cf https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/remapping.20of.20the.20standard.20library/near/564093571
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Dec 17, 2025
@Urgau
Copy link
Member Author

Urgau commented Dec 17, 2025

@bors try

rust-bors bot added a commit that referenced this pull request Dec 17, 2025
Prefer remapping the relative `library/` and `compiler/` directories
@rust-bors

This comment has been minimized.

@rust-bors
Copy link

rust-bors bot commented Dec 17, 2025

☀️ Try build successful (CI)
Build commit: 7b8f45c (7b8f45c196d5f10b2f859b09c58205f9f9228066, parent: 68f11a11b666b36137374b6e54fc0d013a3b26cf)

Copy link
Member

@jieyouxu jieyouxu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, let give this a try at least. If this proves problematic, we can revert.

View changes since this review

@jieyouxu
Copy link
Member

@bors r+ rollup=never

@bors
Copy link
Collaborator

bors commented Dec 18, 2025

📌 Commit 74eecf9 has been approved by jieyouxu

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Dec 18, 2025
@bors
Copy link
Collaborator

bors commented Dec 18, 2025

⌛ Testing commit 74eecf9 with merge 0e7ebb4...

bors added a commit that referenced this pull request Dec 18, 2025
Prefer remapping the relative `library/` and `compiler/` directories

This is done to avoid leaking the relative paths to the standard library after the overall of filenames in #149709.

Noted that the paths were already leaking before, but to a lesser extent since most (but not all) the paths embedded in the distributed `rlib` were absolute.

In general Cargo compiles workspace members with relative paths, so it's better anyway to remap the relative path.

In addition to our tests I have manually confirmed that it also works as expected for the printed diagnostics paths.

cf. https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/remapping.20of.20the.20standard.20library/near/564093571
@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Collaborator

bors commented Dec 18, 2025

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Dec 18, 2025
@jieyouxu
Copy link
Member

Huh.

@Urgau
Copy link
Member Author

Urgau commented Dec 18, 2025

Those tests failures are interesting, they show the remapped paths, despite compiletest asking rustc to change the prefix to /rustc/FAKE_PREFIX (with -Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX).

I have manually checked and the above prefix change works as expected for imported files (ie files described in rmeta), but as far as I can tell none of those filenames comes from an rlib/rmeta.

Instead they come from the compiled artifact it-self, and more specifically the debuginfo, which is retrived by the backtraces and shown on those tests. (yes, even in the note:, thanks to some wild backtrace capturing in rustc_errors)

The reason this wasn't an issue before is because were only producing the relative paths, which are not remapped before this PR. As for why those tests didn't fail on PR CI, I have no idea.


In any-case we well need a mechanism that supplants the current /rustc/FAKE_PREFIX normalization.

This is even complicated by the fact depending on whenever the compiler/std was compiled with remapping on or off changes the kind of paths we get, as with remapping on we will get absolute paths (starting with /rustc/) but with remapping off we will only get relative paths, which I think prevents us from applying any normalization globally.

Given that all of those test already had custom normalization for those backtrace paths, I have opted to add a simple //@ normalize-stderr: "/rustc(?:-dev)?/[a-z0-9.]+/" -> "" rule to all of the failing tests.

@Urgau
Copy link
Member Author

Urgau commented Dec 18, 2025

@bors try jobs=dist-x86_64-linux

@rust-bors

This comment has been minimized.

rust-bors bot added a commit that referenced this pull request Dec 18, 2025
Prefer remapping the relative `library/` and `compiler/` directories

try-job: dist-x86_64-linux
@rust-bors
Copy link

rust-bors bot commented Dec 19, 2025

☀️ Try build successful (CI)
Build commit: 3822c58 (3822c58804c3d0f64dd4e612587894ac319d5d22, parent: fcf67da039f42e3905cf6f69e33304299c45149f)

Copy link
Member

@jieyouxu jieyouxu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm... yeah. The extra test normalizations don't feel great, but not end of the world.

View changes since this review

@jieyouxu
Copy link
Member

@bors r+

@bors
Copy link
Collaborator

bors commented Dec 19, 2025

📌 Commit 0acc846 has been approved by jieyouxu

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Dec 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants